package week01

import "math"

// 11. 盛最多水的容器
// https://leetcode-cn.com/problems/container-with-most-water/submissions/

// 双指针

func maxArea(height []int) int {
	var ans = 0
	var l, r = 0, len(height)-1
	for l < r {
		ans = max(ans, min(height[l], height[r]) * (r - l))
		if height[l] < height[r] {
			l++
		} else {
			r--
		}
	}

	return ans
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}